package com.jsoft.service;

import com.jsoft.dto.RecipeDto;
import com.jsoft.manager.RecipeManager;
import com.jsoft.model.RecipeDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.List;

/**
 * Date: 05.09.13
 * Time: 11:33
 */

@Service
public class RecipeServiceImpl implements RecipeService {
    @Autowired
    private RecipeManager recipeManager;

    @Override
    @Transactional(readOnly = true)
    public List<RecipeDto> getRecipeListByGroupId(Integer groupId) {
        List<RecipeDao> recipeDaoList = recipeManager.getListByGroupId(groupId);
        List<RecipeDto> recipeDtoList = new ArrayList<RecipeDto>();
        for (RecipeDao dao : recipeDaoList) {
            recipeDtoList.add(dao.wrapRecipeDto());
        }
        return recipeDtoList;
    }
}
